package com.cgnpc.scp.common.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * <p>
 * 定时器配置；添加注解
 *
 * @ EnableScheduling
 * @ EnableAsync
 * </p>
 */
@Configuration
@EnableScheduling
@EnableAsync
public class ExecutorConfig {
    private static final Logger LOGGER = LoggerFactory.getLogger(ExecutorConfig.class);

//    /**
//     * 创建定时器线程池，看实际情况是否需要额外配置。
//     */
//    @Bean
//    public TaskScheduler taskScheduler() {
//        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
//        taskScheduler.setPoolSize(50);
//        return taskScheduler;
//    }

    @Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
    // @Scheduled(cron = "0/10 * * * * ?") // 每10钟执行一次
    public void testTask() {
        LOGGER.info("ExecutorConfig.testTask.run;");
    }

}
